<html>
  <head>
    <title>View Sample</title> 
      <hta:application
        id="objView"
        applicationname="appView"
        scroll="no"
        singleinstance="yes"
        windowstate="normal"
        border="thin" />

      <script language="VBScript" type="text/vbscript">
'<![CDATA[

''= on load body: fill ListView
' ============================================================================ 

Sub onloadBody()
' MsgBox "onloadBody()"

  Dim oLV : Set oLV = document.getElementById( "lvListView" )
  If oLV Is Nothing Then
     MsgBox "oLV Is Nothing"
  Else
     Const cnRows = 30
     Const cnCols =  3
     Dim nRow, nCol, oLI

     With oLV
       .View   = 3
       .Width  = 300
       .Height = 400

       .ColumnHeaders.Clear
       For nCol = 1 To cnCols
         .ColumnHeaders.Add , , "Col " & nCol, 100
       Next

       .ListItems.Clear
       For nRow = 1 To cnRows
           Set oLI = .ListItems.Add
           oLI.Text = "R" & nRow & "C1"
           For nCol = 2 To cnCols
               oLI.ListSubItems.Add.Text = "R" & nRow & "C" & nCol
           Next
       Next
     End With
  End If
End Sub

''= refreshes the HTA page, which includes re-running any Windows_Onload code
' ============================================================================ 

Sub reloadHTA()
  location.reload(True)
End Sub

']]>
      </script>
    </head>
    <body onload = "onloadBody()">
      <hr />
      <form>
      <table border = "1">
        <tr>
        <td>
          <object id="lvListView" classid="clsid:BDD1F04B-858B-11D1-B16A-00C0F0283628"></object>
        </td>
        </tr>
      </table>
      <input type="BUTTON" value="reload" onclick="reloadHTA()">
      </form>
    </body>
</html>
